{include file="public/header" /}
<style>
    .layui-input-block{width: 80%}
    .layui-form-radio>.lay-skin-tag,
    .layui-form-checkbox>.lay-skin-tag{
        font-size: 13px;
        border-radius: 5px;
        height: 25px;
        line-height: 25px;
        margin-top: 7px;
        margin-right: 10px;
        color: #fff !important;
        background: #d2d2d2 !important;
    }
    .layui-form-checked>.lay-skin-tag,
    .layui-form-radioed>.lay-skin-tag {
        background-color: #16b777 !important;
    }
</style>
<body>
<div class="x-body">
    <form action="{:url('save')}" class="layui-form" id="form">
        <input type="hidden" name="id" id="id" value="{$info?$info.id:''}"/>
        <div class="layui-form-item">
            <label class="layui-form-label">题目 </label>
            <div class="layui-input-block">
                <input type="text" name="title" value="{$info?$info.title:''}" placeholder="请输入题目" lay-verify="required"
                       class="layui-input"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">考试密码 </label>
            <div class="layui-input-inline">
                <input type="password" name="password" value="" placeholder="请输入考试密码" class="layui-input"/>
            </div>
            <div class="layui-form-mid layui-word-aux">*默认为111111</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">分类</label>
            <div class="layui-input-block">
                {volist name="cate" id="vo" key="k"}
                <input type="radio" name="cate" value="{$vo.id}" lay-filter="type_radio" title="{$vo.title}" lay-skin="none" {notempty name="info"}{if $info.cate == $vo.id} checked {/if} {/notempty}>
                <div lay-radio class="lay-skin-tag layui-badge">{$vo.title}</div>
                {/volist}
            </div>
        </div>
        <!-- <div class="layui-form-item">
            <label class="layui-form-label">考试类型</label>
            <div class="layui-input-block">
                <input type="radio" name="types" value="1" title="初考" lay-skin="none" {notempty name="info"}{if $info.types == 1} checked {/if} {/notempty}>
                <div lay-radio class="lay-skin-tag layui-badge">初考</div>
                <input type="radio" name="types" value="2" title="补考" lay-skin="none" {notempty name="info"}{if $info.types == 2} checked {/if} {/notempty}>
                <div lay-radio class="lay-skin-tag layui-badge">补考</div>
            </div>
        </div> -->
        <input type="hidden" name="types" value="1"/>
        <div class="layui-form-item">
            <label class="layui-form-label">考试日期</label>
            <div class="layui-input-block">
                <input type="text" name="exam_date"  placeholder="yyyy-MM-dd" readonly  value="{$info?$info.exam_date:''}" lay-verify="required" placeholder="yyyy-MM-dd"
                lay-reqtext="请选择考试日期" class="layui-input" lay-verType="tips"  id="exam_date">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">考试时间</label>
            <div class="layui-input-block">
                <input type="text" name="exam_time"  readonly  value="{$info?$info.exam_time:''}" lay-verify="required" placeholder=" - "
                lay-reqtext="请选择考试时间" class="layui-input" lay-verType="tips"  id="exam_time">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">考生</label>
            <div class="layui-input-block" id="userlist">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label req">考试介绍</label>
            <div class="layui-input-block">
                <?php $data = isset($info)?$info:[];?>
                {table:alone view='items/editor' info='$data' form='["field" => "content"]'/}
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <button class="layui-btn" lay-filter="save" lay-submit formObj="#form">保存</button>
        </div>
    </form>
</div>

</body>
{include file="public/footer" /}
<script>
$(function(){
 getuser("{$info?$info.cate:'0'}","{$info?$info.id:'0'}");
})
layui.form.on("radio(type_radio)", function(data){
    getuser(data.value,$("#id").val());
});
function getuser(cate,id){
    layer.load(2);
    $.get("{:URL('examine/getUser')}", {cate:cate,id:id},function(data){
        layer.closeAll()
        $("#userlist").empty();
        var html='';
        if(data.code == 1){
            $.each(data.data, function(i, item){
                html += '<input type="checkbox" name="uid[]" value="'+item.id+'" title="'+item.rname+'" '+(item.check == 1?'checked':'')+(item.disabled == 1?' disabled':'')+'/>';
            });
        }else{
            html = '';
        }
        $("#userlist").html(html);
        layui.form.render('checkbox');
    });
}

layui.laydate.render({
    elem: '#exam_date' //指定元素
});
 // 时间范围
 layui.laydate.render({
    elem: "#exam_time",
    type: "time",
    range: true,
    shortcuts: [
      {
        text: '09:30 <p style="text-align: center;">到</p> 11:30',
        value: (function () {
          var date1 = new Date();
          date1.setHours(9, 0, 0, 0);
          var date2 = new Date();
          date2.setHours(11, 30, 0, 0);
          return [date1, date2];
        })
      },
      {
        text: '13:00 <p style="text-align: center;">到</p> 15:00',
        value: (function () {
          var date1 = new Date();
          date1.setHours(13, 0, 0, 0);
          var date2 = new Date();
          date2.setHours(15, 0, 0, 0);
          return [date1, date2];
        })
      }
    ]
  });
</script>
</html>